package com.hamster.crmpre.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hamster.crmpre.pojo.Customer;
import com.hamster.crmpre.pojo.CustomerVipRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Tarry
 * @create 2020/1/8 10:29
 */
@Mapper
@Repository
public interface CustomerVipRecordMapper extends BaseMapper<CustomerVipRecord> {
//TODO 有BUG
    @Select("SELECT B.alipay,B.balance,B.bank_number,B.branch_attribute,B.branch_company_id,B.business_project,B.children_age,B.department,B.developer_id,B.gender,B.have_lessons,B.id,B.id_number,B.institutional_problem,B.marriage,B.name,B.organization,B.payment,B.phone,B.position,B.project_id,B.project_title,B.region,B.teacher_number,B.type,B.wx_number FROM customer_vip_record A,customer B WHERE A.vip_id=#{id} AND B.id = A.customer_id")
    @Results({
            @Result(property = "id",column = "id",id = true),
            @Result(property = "alipay",column = "alipay"),
            @Result(property = "balance",column = "balance"),
            @Result(property = "bankNumber",column = "bank_number"),
            @Result(property = "branchAttribute",column = "branch_attribute"),
            @Result(property = "branchCompanyId",column = "branch_company_id"),
            @Result(property = "businessProject",column = "business_project"),
            @Result(property = "childrenAge",column = "children_age"),
            @Result(property = "department",column = "department"),
            @Result(property = "developerId",column = "developer_id"),
            @Result(property = "gender",column = "gender"),
            @Result(property = "haveLessons",column = "have_lessons"),
            @Result(property = "idNumber",column = "id_number"),
            @Result(property = "institutionalProblem",column = "institutional_problem"),
            @Result(property = "marriage",column = "marriage"),
            @Result(property = "name",column = "name"),
            @Result(property = "organization",column = "organization"),
            @Result(property = "payment",column = "payment"),
            @Result(property = "phone",column = "phone"),
            @Result(property = "position",column = "position"),
            @Result(property = "projectId",column = "project_id"),
            @Result(property = "projectTitle",column = "project_title"),
            @Result(property = "region",column = "region"),
            @Result(property = "teacherNumber",column = "teacher_number"),
            @Result(property = "type",column = "type"),
            @Result(property = "wxNumber",column = "wx_number")
    })
    List<Customer> customerListByVip(String id);


}
